﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:prims="clr-namespace:Microsoft.Practices.Prism.Regions;assembly=Microsoft.Practices.Prism"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" x:Name="window" mc:Ignorable="d" x:Class="MyStockViewer.Shell"
        Title="Shell" MinHeight="346" MinWidth="500" Width="Auto" Height="Auto" Style="{DynamicResource WindowStyle1}" WindowStyle="None" Background="{x:Null}">
	<Window.Resources>
		<ControlTemplate x:Key="WindowTemplateKey" TargetType="{x:Type Window}">
			<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
				<Grid>
					<AdornerDecorator>
						<ContentPresenter/>
					</AdornerDecorator>
					<ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="false" Visibility="Collapsed" VerticalAlignment="Bottom"/>
				</Grid>
			</Border>
			<ControlTemplate.Triggers>
				<MultiTrigger>
					<MultiTrigger.Conditions>
						<Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
						<Condition Property="WindowState" Value="Normal"/>
					</MultiTrigger.Conditions>
					<Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
				</MultiTrigger>
			</ControlTemplate.Triggers>
		</ControlTemplate>
		<Style x:Key="WindowStyle1" TargetType="{x:Type Window}">
			<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
			<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Window}">
						<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
							<AdornerDecorator>
								<ContentPresenter/>
							</AdornerDecorator>
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Style.Triggers>
				<Trigger Property="ResizeMode" Value="CanResizeWithGrip">
					<Setter Property="Template" Value="{StaticResource WindowTemplateKey}"/>
				</Trigger>
			</Style.Triggers>
		</Style>
	</Window.Resources>
    <Border
		Height="Auto"
		Width="Auto" BorderBrush="{DynamicResource Background}" CornerRadius="5" BorderThickness="2">
		<Grid Background="#FF525354">
			<Grid.RowDefinitions>
				<RowDefinition Height="35" />
				<RowDefinition Height="63.899"/>
				<RowDefinition />
			</Grid.RowDefinitions>
			<ContentControl
				prims:RegionManager.RegionName="ToolBarContentRegion" Background="Green" Grid.Row="1" />
			<ItemsControl
				prims:RegionManager.RegionName="MainContentRegion"
				Background="Gray" Grid.Row="2" d:LayoutOverrides="GridBox" />
			<Border MouseLeftButtonDown="DragWindow">
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition/>
						<ColumnDefinition Width="Auto" MinWidth="104"/>
					</Grid.ColumnDefinitions>
					<TextBlock TextWrapping="Wrap" Text="Stock Explorer" VerticalAlignment="Center" Margin="10,0,0,0" HorizontalAlignment="Left" FontWeight="Bold"/>
					<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0">
						<Button x:Name="btnMinimize" Content="_" Width="30" Height="30" Panel.ZIndex="5" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,2,0" Click="btnMinimize_Click"/>
						<Button x:Name="BtnMaximize" Content="M" Width="30" Height="30" Panel.ZIndex="5" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,2,0">
							<i:Interaction.Triggers>
								<i:EventTrigger SourceObject="{Binding ElementName=btnMinimize}" SourceName="btnMinimize" EventName="Click">
									<ei:ChangePropertyAction TargetObject="{Binding ElementName=window}" PropertyName="WindowState">
										<ei:ChangePropertyAction.Value>
											<WindowState>Maximized</WindowState>
										</ei:ChangePropertyAction.Value>
									</ei:ChangePropertyAction>
								</i:EventTrigger>
							</i:Interaction.Triggers>
						</Button>
						<Button x:Name="BtnClose" Content="X" Width="30" Height="30" Panel.ZIndex="5" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,2,0" Click="BtnClose_Click"/>
					</StackPanel>
				</Grid>
			</Border>
		</Grid>
	</Border>
</Window>
